<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: css"></head>
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">

    <!--页面主要内容-->
    <main class="lyear-layout-content" style="padding-top:0px">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-body">
                
                <form class="site-form" id="signupForm">
                  <div class="form-group">
                    <label for="oldPwd">旧密码</label>
                    <input type="password" class="form-control" name="oldPwd" id="oldPwd" placeholder="输入账号的原登录密码">
                  </div>
                  <div class="form-group">
                    <label for="newPwd2">新密码</label>
                    <input type="password" class="form-control" name="newPwd2" id="newPwd2" placeholder="输入新的密码">
                  </div>
                  <div class="form-group">
                    <label for="newPwd">确认新密码</label>
                    <input type="password" class="form-control" name="newPwd" id="newPwd" placeholder="再次输入新的密码">
                  </div>
                  <button type="button" id="submit" class="btn btn-primary">修改密码</button>
                </form>
       
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>
<div th:include="include :: footer"></div>
<script>
  $("#submit").click(function () {
    var oldPwd = $("#oldPwd").val();
    var newPwd2 = $("#newPwd2").val();
    var newPwd = $("#newPwd").val();
    if(newPwd2 == null || newPwd == null || newPwd2 == "" || newPwd==null){
      layer.msg('密码不能为空！');
    }else if(newPwd != newPwd2){
      layer.msg('两次密码不一致！');
    }else if(newPwd == oldPwd || oldPwd ==  newPwd2){
      layer.msg('与原密码相同！');
    }else{
      $.ajax({
        cache: true,
        type:'Post',
        url:'/user/editPwd',
        async: false,
        data : $('#signupForm').serialize(),// 你的formid
        success: function (data) {
          if(data.code == 0){
            parent.layer.msg(data.msg);
            var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
            parent.layer.close(index);
          }else{
            layer.msg(data.msg);
          }
        },error:function (data) {
          layer.msg('修改失败，请联系管理员！');
        }
      });
    }
  });




</script>
</body>
</html>